home *** CD-ROM | disk | FTP | other *** search
- function GETKEY: integer;
-
- { Wait for a single keypress from the keyboard. Valid keys are 1 thru 9,
- and the function keys from 1 thru 9. Getkey returns an integer
- equal to the value of the keypress (PF1 considered identical to the
- digit 1).
- }
- var c: char; { value from keypress }
- Result: integer; { result of keypress }
-
- begin
-
- { clear keyboard buffer }
- while keypressed do
- c := readkey;
-
- { Pause for Keypress }
- while (NOT keypressed) do
- c := ' ';
-
- c := readkey;
- if (c = #0) and (keypressed) then begin { NUL character (fcn key) }
- c := readkey;
- Result := ord(c) - 58;
- { Treat a spacebar like a 0 }
- end else if (ord(c) = 32) then
- Result := 0
- else
- Result := ord(c) - 48;
- if (Result > 0) and (Result < 10) then
- Getkey := Result
- else
- Getkey := 0;
- end; { function GETKEY }